<template>
  <div workbench-ask-list class="wrap-list">
    <router-link tag="div" class="index-list-box" v-for="(items,i) in dataList" :key="i" :to="{name:'taskDetail',query:{id:items.id,uid:items.uid,sour:items.sour}}">
     <div style="margin-top:20px;position:relative;" class="box-inner">
        <div class="item">
        <div class="cell">
          <img :src="items.headimgurl?items.headimgurl:'/static/img/person2.jpg'" alt="">
          <div class="text">
            <h3>{{items.uname}}</h3>
            <span>{{items.type}}</span>
          </div>
        </div>
        <i>{{items.showprice}}元</i>
      </div>
      <div class="center">
        <div>
           <p>{{items.name}}</p>
          <p>要求：{{items.describe}}</p>
          <p>任务周期：{{items.time}}</p>
        </div>
      </div>
      <!-- <slot name="bottom"></slot> -->
     </div>
    </router-link>

  </div>
</template>
<style scoped lang="less" src="./style.less"></style>
<script src="./script.js"></script>

<script>
export default {
  props:['type'],
  data() {
    return {
      dataList: []
    };
  },
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    payTest: function() {
      this.axios.get("/api/wxpay").then(result => {
        console.log("=====");
        console.log(result.data);
        function onBridgeReady() {
          window.WeixinJSBridge.invoke(
            "getBrandWCPayRequest",
            {
              appId: result.data.appId,
              timeStamp: result.data.timeStamp,
              nonceStr: result.data.nonceStr,
              package: result.data.package,
              signType: "MD5",
              paySign: result.data.paySign
            },

            function(res) {
              if (res.err_msg == "get_brand_wcpay_request:ok") {
                // 使用以上方式判断前端返回,微信团队郑重提示：
                //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                alert(JSON.stringify(res));
              } else {
                alert(JSON.stringify(res));
              }
            }
          );
        }
        if (typeof WeixinJSBridge == "undefined") {
          if (document.addEventListener) {
            document.addEventListener(
              "WeixinJSBridgeReady",
              onBridgeReady,
              false
            );
          } else if (document.attachEvent) {
            document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
            document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
          }
        } else {
          onBridgeReady();
        }
      });
    },
    payTest2: function() {
      this.axios.get("/api/wxpay2").then(result => {
        console.log("=====");
        console.log(result.data);
        function onBridgeReady() {
          window.WeixinJSBridge.invoke(
            "getBrandWCPayRequest",
            {
              appId: result.data.appId,
              timeStamp: result.data.timeStamp,
              nonceStr: result.data.nonceStr,
              package: result.data.package,
              signType: result.data.signType,
              paySign: result.data.paySign
            },

            function(res) {
              if (res.err_msg == "get_brand_wcpay_request:ok") {
                // 使用以上方式判断前端返回,微信团队郑重提示：
                //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                alert("ok");
                alert(JSON.stringify(res));
              } else {
                alert(JSON.stringify(res));
              }
            }
          );
        }
        if (typeof WeixinJSBridge == "undefined") {
          if (document.addEventListener) {
            document.addEventListener(
              "WeixinJSBridgeReady",
              onBridgeReady,
              false
            );
          } else if (document.attachEvent) {
            document.attachEvent("WeixinJSBridgeReady", onBridgeReady);
            document.attachEvent("onWeixinJSBridgeReady", onBridgeReady);
          }
        } else {
          onBridgeReady();
        }
      });
    },
    init() {
      let path="/api/showTaskList";
      if(this.type === "offline"){
        path = "/api/offline/tasklist";
      }
      else if(this.type === "skill"){
        //path = "/api/skill/tasklist"
        path = "";
      }
      else if(this.type === "other"){
        //path = "/api/skill/tasklist"
        path = "";
      }
      if(path!==""){
      this.axios
        .get(path, {
          params: { uid: JSON.parse(sessionStorage.getItem("user")).uid }
        })
        .then(res => {
          if(res.data.err_code === 0){
            this.dataList = res.data.data;
          }
          console.log(res.data);
        });
      }
    }
  }
};
</script>
<style lang="less" scoped>
.wrap-list{
  background: #F8FAFE;
  margin-bottom: 60px;
}
.index-list-box{
  background: #fff;
  display: block;
  margin-bottom: 20px;
  margin-top: 20px;

}
</style>

